package com.lengtouzai.databaseexp.entity;

import io.jmix.core.entity.annotation.JmixGeneratedValue;
import io.jmix.core.metamodel.annotation.InstanceName;
import io.jmix.core.metamodel.annotation.JmixEntity;
import jakarta.persistence.*;

import java.util.List;
import java.util.UUID;

@JmixEntity
@Table(name = "EXP_FRIEND_GROUP", indexes = {
        @Index(name = "IDX_EXP_FRIEND_GROUP_BELONGS", columnList = "BELONGS_ID")
})
@Entity(name = "exp_FriendGroup")
public class FriendGroup {
    @JmixGeneratedValue
    @Column(name = "ID", nullable = false)
    @Id
    private UUID id;

    @Column(name = "VERSION", nullable = false)
    @Version
    private Integer version;

    @InstanceName
    @Column(name = "NAME")
    private String name;

    @OneToMany(mappedBy = "belongs")
    private List<Friend> friends;

    @JoinColumn(name = "BELONGS_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private User belongs;

    public User getBelongs() {
        return belongs;
    }

    public void setBelongs(User belongs) {
        this.belongs = belongs;
    }

    public List<Friend> getFriends() {
        return friends;
    }

    public void setFriends(List<Friend> friends) {
        this.friends = friends;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }
}